package com.qf.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import javax.sql.DataSource;

@Configuration
@ComponentScan(basePackages ="com.qf")
@PropertySource("classpath:druid.properties")
public class SpringConfig {
//    @Value("${druid.driverClassName}")
    private String driverClass;
//    @Value("${druid.url}")
    private String url;
//    @Value("${druid.username}")
    private String username;
//    @Value("${druid.password}")
    private String password;

    public DataSource getDataSource(){
        DruidDataSource dataSource=new DruidDataSource();
        dataSource.setDriverClassName(driverClass);
        dataSource.setUrl(url);
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        return dataSource;
    }
}
